import 'dart:io';

import 'package:device_info/device_info.dart';
import 'package:flutter/services.dart';

abstract class TDevice {
  static Future<String> getDeviceUuid() async {
    String identifier;
    final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
    try {
      if (Platform.isAndroid) {
        var build = await deviceInfoPlugin.androidInfo;
        identifier = build.androidId; //UUID for Android
      } else if (Platform.isIOS) {
        var data = await deviceInfoPlugin.iosInfo;
        identifier = data.identifierForVendor; //UUID for iOS
      }
    } on PlatformException {}
    return identifier;
  }

  static Future<String> getDeviceName() async {
    String deviceName;

    final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
    try {
      if (Platform.isAndroid) {
        var build = await deviceInfoPlugin.androidInfo;
        deviceName = '${build.brand} ${build.model}';
      } else if (Platform.isIOS) {
        var data = await deviceInfoPlugin.iosInfo;
        deviceName = '${data.model} ${data.name}';
      }
    } on PlatformException {}

    return deviceName?? 'Unknown Device';
  }
}
